#include <iostream>
#include <sstream>
#include <string>
#include "Lexer.h"
#include <cstdlib>


Lexer::Lexer(){
    cin >> this->Input;
    currIndex = 0;
}

Token Lexer::nextToken(){
        char curr = Input[currIndex];
		if (curr == '\0'){
			return Token(Input, END);
		}
        if (isdigit(curr)){
			string s ="PUSH ";
			while(isdigit(curr)){
			s = s + curr; 
			currIndex++;
			curr = Input[currIndex];
			}
            return Token(s, INT);
}
        switch (curr){
        case '+':
			currIndex++;
            return Token("PLUS", PLUS);
        case '*':
			currIndex++;
            return Token("MULT", MULT);
        case '(':
			currIndex++;
            return Token("LPAREN", LPAREN);
        case ')':
			currIndex++;
            return Token("RPAREN", RPAREN);
        default:
			currIndex++;
            return Token("", ERROR);
        }
}
